using System;
using System.Collections.Generic;
using System.Text;

namespace QuanLyKhachSan
{
    public class LoaiPhongDTO
    {
        // Cac thuoc tinh
        private int maLoaiPhong;        
        private string tenLoaiPhong;        
        private float donGia;        
        private int danhDau;        

        // Cac phuong thuc
        public int MaLoaiPhong
        {
            get { return maLoaiPhong; }
            set { maLoaiPhong = value; }
        }

        public string TenLoaiPhong
        {
            get { return tenLoaiPhong; }
            set { tenLoaiPhong = value; }
        }

        public float DonGia
        {
            get { return donGia; }
            set { donGia = value; }
        }

        public int DanhDau
        {
            get { return danhDau; }
            set { danhDau = value; }
        }

         
            
        // Kiem tra dieu kien
        
        //Kiem tra don gia co phai la kieu so nguyen hay khong
        public static bool KiemTraDonGia(string donGia)
        {
            if (string.IsNullOrEmpty(donGia) == false)
            {
                int kq;
                if (int.TryParse(donGia, out kq) == false)
                    return false;
                else if (kq < 0)
                    return false;
                return true;
            }
            return true ;
        }

        // Kiem tra du lieu
        static public bool KiemTraTenLoaiPhong(string tenLoaiPhong)
        {
            if (string.IsNullOrEmpty(tenLoaiPhong) == false)//neu no ko trong moi kiem tra tiep
            {
                // khong la so
                double kq;
                if (double.TryParse(tenLoaiPhong, out kq) == true)
                    return false;
                // Kiem tra giua 2 chu chi co khoang trang
                if (tenLoaiPhong.IndexOf("  ") != -1)
                    return false;
                int i;
                // Kiem tra co ki tu ~ hay khong
                for (i = 0; i < tenLoaiPhong.Length; i++)
                {
                    if (tenLoaiPhong[i] == '~')
                        return false;
                }
                // Kiem tra cac ky tu dau phai ky tu hoa
                string[] arr = tenLoaiPhong.Split(' ');

                for (i = 0; i < arr.Length; i++)
                {
                    if (char.IsLower(arr[i][0]) == true)//co loi khi ten loai phong =""
                        return false;
                }
            }
            return true ;
        }
        
    }
}
